/// **************************************************************************************************
/// "Copyright (c) 2007 Sai Panyam, Inc.  All rights reserved."
/// **************************************************************************************************
/// Component Name   :	Alignment, Member of System72.NTextile 
/// Description      :	Alignment holds the operator, style text and alignment type.
/// Author           :	Sai Panyam
/// Creation Date    :	November 09 2007
/// Modified Date    :              
/// Modified By      :
/// **************************************************************************************************
using System;

namespace System72.NTextile
{
    public class Alignment
    {
        #region Private Variables

        private readonly AlignmentType m_alignmentType;
        private string m_operator;
        private string m_alignmentText;

        #endregion
        
        #region Constructors
        /// <summary>
        /// 
        /// </summary>
        /// <param name="alignmentType"></param>
        public Alignment(AlignmentType alignmentType)
        {
            m_alignmentType = alignmentType;
            initializeByAlignmentType();
        }

        #endregion

        #region Public Properties
        /// <summary>
        /// The alignment operator.
        /// </summary>
        public string Operator
        {
            get { return m_operator; }
        }
        /// <summary>
        /// The style string that needs to be put in by the modifier
        /// </summary>
        public string AlignmentText
        {
            get { return m_alignmentText; }
        }
        /// <summary>
        /// The type of alignment.
        /// </summary>
        public AlignmentType AlignmentType
        {
            get { return m_alignmentType; }
        }

        #endregion

        #region Private Methods
        /// <summary>
        /// Assign the Operator and alignment style values based on alignment type.
        /// </summary>
        private void initializeByAlignmentType()
        {
            switch (m_alignmentType)
            {
                case AlignmentType.Center:
                    m_operator = @"=";
                    m_alignmentText = "text-align:center;{0}";//To append style attribute if present
                    break;
                case AlignmentType.Justify:
                    m_operator = @"<>";
                    m_alignmentText = "text-align:justify;{0}";
                    break;
                case AlignmentType.Left:
                    m_operator = @"<";
                    m_alignmentText = "text-align:left;{0}";
                    break;
                case AlignmentType.Right:
                    m_operator = @">";
                    m_alignmentText = "text-align:right;{0}";
                    break;
               default:
                    throw new NotSupportedException("AlignmentType :" + m_alignmentType + " not yet supported");
            }
        }

        #endregion
    }
}
